package com.luoqiu.yygh.user.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.luoqiu.yygh.common.result.Result;
import com.luoqiu.yygh.user.handler.MySentinelHandler;
import com.luoqiu.yygh.user.service.UserInfoService;
import com.luoqiu.yygh.vo.user.LoginVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/api/user")
public class UserInfoApiController {

    @Autowired
    private UserInfoService userInfoService;

    @SentinelResource(value = "login", blockHandlerClass = MySentinelHandler.class, blockHandler = "login_err")
    @PostMapping(value = "/login")
    public  Result<Object> loginPhone(@RequestBody LoginVo loginVo) {
        Object o = userInfoService.loginPhone(loginVo);
        return Result.ok(o);
    }


}
